<template>
  <view>
    <u-swiper :list="swiperList" @click="previewImage"></u-swiper>
  </view>
</template>

<script>
export default {
  data() {
    return {
      swiperList: [
        // 这里填充你的轮播图图片链接
        'https://cdn.uviewui.com/uview/swiper/swiper3.png',
        'https://cdn.uviewui.com/uview/swiper/swiper2.png',
        'https://cdn.uviewui.com/uview/swiper/swiper1.png',
      ]
    };
  },
  methods: {
    previewImage(event) {
      // 获取点击的图片索引
      // debugger
      // const index = this.swiperList.indexOf(event.target.currentSrc);
      const index = event;
      // debugger
      // 使用uView的u-toast组件显示图片预览
      // uni.$u.toast.show({
      //   title: '图片预览',
      //   imageUrl: this.swiperList,
      //   imageIndex: index
      // });

      uni.showToast({
          title: '图片预览',
          imageUrl: this.swiperList,
          imageIndex: index
      })
    }
  }
};
</script>
